//
//  CampusQuestionAddCell.m
//  ShowYork
//
//  Created by hxh on 2021/3/30.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "CampusQuestionAddCell.h"

@interface CampusQuestionAddCell ()
@property (nonatomic,strong)UIView *coverView;
@property (nonatomic,strong)UILabel *addLb;
@property (nonatomic,strong)UIImageView *addIcon;
@property (nonatomic,strong)UIButton *addButton;
@end

@implementation CampusQuestionAddCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.coverView = [[UIView alloc]init];
    self.coverView.backgroundColor = [RPAppManager themColor];
    self.coverView.layer.cornerRadius = 18;
    self.coverView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.coverView];
    [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(36).priorityHigh();
        make.width.mas_equalTo(140);
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(64);
        make.bottom.equalTo(self.contentView).offset(-84);
    }];
    
    self.addIcon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"campus_add_question_tag"]];
    [self.contentView addSubview:self.addIcon];
    [self.addIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.coverView);
        make.left.equalTo(self.coverView).offset(30);
    }];
    self.addLb = [[UILabel alloc]init];
    self.addLb.text = @"发起提问";
    self.addLb.textColor = [UIColor whiteColor];
    self.addLb.font = font(14);
    [self.contentView addSubview:self.addLb];
    [self.addLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.coverView);
        make.left.equalTo(self.addIcon.mas_right).offset(8);
    }];
    
    self.addButton = [[UIButton alloc]init];
    [self.addButton addTarget:self action:@selector(addMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.addButton];
    [self.addButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.coverView);
    }];
}
- (void)addMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(addQuestion)]) {
        [self.delegate addQuestion];
    }
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"CampusQuestionAddCell";
    CampusQuestionAddCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[CampusQuestionAddCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
@end
